package ro.ubbcluj.cs.damate.services;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import ro.ubbcluj.cs.damate.persistence.entities.Section;
import ro.ubbcluj.cs.damate.persistence.repository.SectionRepository;

import java.util.List;

/**
 * @author Lóránd Fazakas (lorand)
 *         Date: 5/10/12
 *         Time: 9:49 PM
 */
@Service
public class SectionService {

    @Autowired
    private SectionRepository sectionRepository;

    @Transactional
    public void create(Section transientSection) {
        sectionRepository.save(transientSection);
    }

    @Transactional
    public void update(Section persistentSection) {
        sectionRepository.save(persistentSection);
    }

    @Transactional
    public void delete(Section persistentSection) {
        sectionRepository.delete(persistentSection);
    }

    public Section findById(Long id) {
        return sectionRepository.findOne(id);
    }

    public List<Section> findAll() {
        return sectionRepository.findAll();
    }
}
